package com.ctshk.sapp.order.goods.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.order.goods.dto.WriteOffRecordPageListDTO;
import com.ctshk.rpc.order.goods.req.OrderPageListPageReq;
import com.ctshk.rpc.order.goods.req.WriteOffRecordReq;
import com.ctshk.rpc.order.goods.service.IWriteOffRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 核销记录表 前端控制器
 * </p>
 *
 * @author 姜斌文
 * @since 2021-04-29
 */
@Api(value="核销记录", tags="核销记录")
@RestController
@RequestMapping("/write/off/record")
public class WriteOffRecordController extends BaseController {


    @DubboReference
    private IWriteOffRecordService writeOffRecordService;

    @ApiOperation(value = "订单核销", notes = "订单核销")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "订单核销", operDesc = "订单核销")
    @PostMapping("/orderWriteOff")
    public Result orderWriteOff(@RequestBody @Valid WriteOffRecordReq req) throws Exception {
        writeOffRecordService.orderWriteOff(req, getCurrentUser(getRequest()));
        return Result.success();
    }

    @ApiOperation(value = "商品訂單分頁列表", notes = "商品訂單分頁列表")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "商品訂單分頁列表", operDesc = "商品訂單分頁列表")
    @PostMapping("/orderWriteOffRecordPageList")
    public PageResponse<WriteOffRecordPageListDTO> orderWriteOffRecordPageList(@RequestBody @Valid OrderPageListPageReq req ){
        return writeOffRecordService.orderWriteOffRecordPageList(req, getCurrentUser(getRequest()));
    }
}
